import { createPinia } from "pinia";
import { createPersistedState } from "pinia-plugin-persistedstate";
// 导出modules下面的所有仓库
import { useMemberStore } from "./modules/menber";

const pinia = createPinia();

// 组合api添加$reset方法，用于重置状态
pinia.use(({ store }) => {
  const initialState = JSON.parse(JSON.stringify(store.$state));
  store.$reset = () => {
    store.$patch(initialState);
  };
});
pinia.use(
  createPersistedState({
    storage: localStorage,
  })
);

export default pinia;
export { useMemberStore };
